<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Helper for the AuthorEyes library
 * 
 * @package     AuthorEyes
 * @subpackage  Helper
 * @category    Authentication
 * @author      Patrick Clark (Tap)
 * @copyright   Copyright (c) 2008, pubblichi.com
 * @license     http://www.gnu.org/licenses/lgpl.html
 * @link        http://www.pubblichi.com/authoreyes
 * @info        This is an adaptation of the FreakAuth Light authentication library 
 * @info        written specifically for Kohana.
 * @info     	FreakAuth Light written by Daniel Vecchiato (danfreak) & Christophe Gragnic (grahack)
 * @info        Visit www.4webby.com/freakauth to download FreakAuth Light for CodeIgniter
 * @version     0.1
 */
	
class authoreyes_help_Core {
	/**
	 * Generates a random string.
	 *
	 * @param  int    Length of the string ($length).
	 * @return string
	 */
	public static function generate_random_string_captcha($length)
	{
		if (Config::item('authoreyes.ae_captcha_settings.use_numbers') AND
			Config::item('authoreyes.ae_captcha_settings.use_letters'))
		{
			$key = text::random('alnum', $length);
		}
		elseif (Config::item('authoreyes.ae_captcha_settings.use_numbers') AND
				!Config::item('authoreyes.ae_captcha_settings.use_letters'))
		{
			$key = text::random('numeric', $length);
		}
		elseif (Config::item('authoreyes.ae_captcha_settings.use_letters') AND
				!Config::item('authoreyes.ae_captcha_settings.use_numbers'))
		{
			$key = text::random('alpha', $length);
		}
		else
		{
			throw new Kohana_Exception('authoreyes.ae_captcha.captcha_key_spec_missing');
		}
		
		return $key;
	}
	
	
} // End authoreyes
?>
